package com.recommend.recommendkeyword.controller;

import com.recommend.recommendkeyword.common.CommonResponse;
import com.recommend.recommendkeyword.entity.Keywords;
import com.recommend.recommendkeyword.service.TagService;
import com.recommend.recommendkeyword.vo.TagVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/tag")
public class TagController {
    @Autowired
    private TagService tagService;

    /**
     * 根据标签来查询关键词
     */
    @GetMapping("/keyword")
    public CommonResponse<List<TagVo>> selectKeywordByTag(){
        List<TagVo> tagVos = tagService.getKeywordListByTag();
        if (tagVos == null || tagVos.isEmpty())
            return CommonResponse.createForError("此标签中的关键词为空!");
        return CommonResponse.createForSuccess(tagVos);
    }

}
